﻿// Sheego.Service.X400
// Copyright(C) 2015 Schwab Versand GmbH
//
// This source file is subject to the Microsoft Public License(Ms-PL).
// http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Castle.Windsor.Installer;
using Sheego.Service.X400.Job.Shared.BO;
using Sheego.Service.X400.Job.Shared.Comparer;
using Sheego.Service.X400.Job.Shared.Matcher;
using Sheego.Service.X400.Job.Shared.Parser;
using Sheego.Service.X400.Job.Shared.Processor;
using Sheego.Service.X400.Scheduler.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sheego.Service.X400.Job.Shared.Locator
{
    public class JobLocator
    {
        private static WindsorContainer _container = null;
        private static WindsorContainer Container
        {
            get
            {
                if (_container == null)
                {
                    _container = new WindsorContainer();
                    _container.Install(FromAssembly.Named("Sheego.Service.X400.Job.Impl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0c657262f77b6bfb"));
                }
                return _container;
            }
        }

        public static void Reset()
        {
            _container = null;
        }


        public static void Register<T1>(T1 instance) where T1 : class
        {
            Container.Register(Component.For<T1>().Instance(instance).IsDefault());
        }


        public static IJob GetJob()
        {
            return Container.Resolve<IJob>();
        }


        public static IJobLogger GetLogger()
        {
            return Container.Resolve<IJobLogger>();
        }

        public static IUAFIProcess GetProcess()
        {
            return Container.Resolve<IUAFIProcess>();
        }

        public static IUAFICommand GetCommand()
        {
            return Container.Resolve<IUAFICommand>();
        }

        public static IUAFICommandFactory GetCommandFactory()
        {
            return Container.Resolve<IUAFICommandFactory>();
        }

        public static IUAFIResponse GetResponse()
        {
            return Container.Resolve<IUAFIResponse>();
        }

        public static IUAFIResponseParser GetResponseParser()
        {
            return Container.Resolve<IUAFIResponseParser>();
        }

        public static IX400MessageParser GetMessageParser()
        {
            return Container.Resolve<IX400MessageParser>();
        }

        public static IFileManager GetFileManager()
        {
            return Container.Resolve<IFileManager>();
        }

        public static IX400MessageRouter GetMessageRouter()
        {
            return Container.Resolve<IX400MessageRouter>();
        }

        public static IX400Message GetMessage()
        {
            return Container.Resolve<IX400Message>();
        }

        public static IX400MessagePart GetMessagePart()
        {
            return Container.Resolve<IX400MessagePart>();
        }

        public static IX400Address GetAddress()
        {
            return Container.Resolve<IX400Address>();
        }

        public static IX400AddressParser GetAddressParser()
        {
            return Container.Resolve<IX400AddressParser>();
        }

        public static IX400Address GetX400Address()
        {
            return Container.Resolve<IX400Address>();
        }

        public static IX400MessageRule GetMessageRule()
        {
            return Container.Resolve<IX400MessageRule>();
        }

        public static IConsoleProcess GetConsoleProcess()
        {
            return Container.Resolve<IConsoleProcess>();
        }

        public static IX400MessageProcessor GetMessageProcessor(string Type)
        {
            return Container.Resolve<IX400MessageProcessor>(Type);
        }

        public static IX400MessageMatcher GetMessageMatcher(string Type)
        {
            return Container.Resolve<IX400MessageMatcher>(Type);
        }

        public static IX400AddressComparer GetAddressComparer()
        {
            return Container.Resolve<IX400AddressComparer>();
        }

        public static IXmlWrapper GetXmlWrapper(string XmlFile, string nsKey, string nameSpace)
        {
            return Container.Resolve<IXmlWrapper>(new { xmlFilePath = XmlFile, keyNameSpace = nsKey, uriNameSpace = nameSpace });
        }

        public static IX400MessageCache GetMessageCache()
        {
            return Container.Resolve<IX400MessageCache>();
        }

        public static IContentType GetContentType()
        {
            return Container.Resolve<IContentType>();
        }

        public static IEDIFACTParser GetEDIFACTParser()
        {
            return Container.Resolve<IEDIFACTParser>();
        }

        public static IEDIFACTParserStream GetEDIFACTParserStream()
        {
            return Container.Resolve<IEDIFACTParserStream>();
        }

        public static IMailManager GetMailManager()
        {
            return Container.Resolve<IMailManager>();
        }

        public static IMailMessage GetMailMessage()
        {
            return Container.Resolve<IMailMessage>();
        }

        public static IMailAttachment GetMailAttachment()
        {
            return Container.Resolve<IMailAttachment>();
        }

        public static IRangeParser GetRangeParser()
        {
            return Container.Resolve<IRangeParser>();
        }

        public static IRange GetRange()
        {
            return Container.Resolve<IRange>();
        }
    }
}
